<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@include file="/init.jsp" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>View Detail Product</title>
</head>
<body>
	<%
		int productId = (request.getParameter("productId") == null) ? 0 : Integer.valueOf(request.getParameter("productId"));
		
		if(productId == 0) {
			%> 
			<h2>Chưa chọn được sản phẩm cần xem</h2>
			<%
		}
		
		else {
			Product product = dataManager.getProductWithProductId(productId);
			
			String urlImage = request.getContextPath() + "/DisplayImage?path=" + product.getImage();			
			System.out.println(urlImage);
			
			%>
			<p><%=product.getProductName() %></p>
			<img src="<%=urlImage %>" />
			<p><%=product.getDescription() %></p>
			<p><%=product.getPrice() %>
			<p><%=product.getQuantity() %></p>
			<%
		}
	%>
</body>
</html>